import http from '@/utils/http/axios'
import { BasicResponseModel } from '@/api/model/baseModel'
import * as userModel from './model/userModel'
import { SmsCodeParams, CaptchaCheckParams, CaptchaGetParams } from './model/userModel'

/**
 * @description: 用户登录
 */
export function login(params: userModel.LoginParams) {
  return http.request<BasicResponseModel<userModel.LoginResultModel>>({
    url: '/api/operator/iu/login',
    method: 'POST',
    params
  })
}

/**
 * @description: 获取用户信息
 */
export function getUserInfo() {
  return http.request<BasicResponseModel<userModel.GetUserInfoResultModel>>({
    url: '/api/operator/info',
    // url: 'https://yapi.madaomall.com/mock/204/operator/info',
    method: 'GET'
  })
}

/**
 * @description: 短信验证码
 */
export function getSmsCode(params: SmsCodeParams) {
  return http.request({
    url: '/api/account/code/iu/sms',
    method: 'POST',
    params
  })
}
/**
 * @description: 短信验证码
 */
export function getPddSmsCode(params: SmsCodeParams) {
  return http.request({
    url: '/api/account/code/iu/sms',
    method: 'POST',
    params
  })
}
/**
 * @description: 获取图形验证码
 */
export function captchaGet(params: CaptchaGetParams) {
  return http.request({
    url: '/api/account/code/iu/captcha',
    method: 'POST',
    params
  })
}

/**
 * @description: 图形验证码验证
 */
export function captchaCheck(params: CaptchaCheckParams) {
  return http.request(
    {
      url: '/api/account/code/iu/check',
      method: 'POST',
      params
    },
    {
      isTransformResponse: false
    }
  )
}
/**
 * @description: 免登
 */
export function delegateLogin(params: any) {
  return http.request({
    url: '/api/account/operator/imcode',
    method: 'GET',
    params,
    headers: {
      ignoreCancelToken: true
    }
  })
}

export default class $api {}
